# -*- coding: utf-8 -*-

import upyun
import hashlib
import os

# 需要填写自己的服务名，操作员名，密码
service = "pumen"
username = "pmt"
password = "yjDafPu3gzh5hQgN8rHMpYyuSGgpOxkc"

# 需要填写上传文件的本地路径和云存储路径
# local_file = "hello.png"
# remote_file = "haha.png"

up = upyun.UpYun(service, username=username, password=password)

def rest_upload(local_image):
    """
    rest文件上传
    """
    # with open(local_file, "rb") as f:
    #     # headers 可选，见rest上传参数
    #     headers = None
    #     response = up.put(remote_file, f, headers=headers)
    #     print(response)

    response = up.put(local_image.name, local_image.read(), headers=None)

    return response


if __name__ == '__main__':
    f = open('hello.png', 'rb')
    rest_upload(f)
